<template>
	<view>
		<!--header-->
		<view class="main-app modal-body">
			<view class="main-content en p-2">
				<!-- 我的直属 -->
				<view class="profile-main-account v0 card">

					<view class="m-0 row">
						<view class="col-2 col">
							<view class="avatar">

								<u--image :showLoading="false" :src="userinfo.user_headimg" width="40"
									height="40"></u--image>
							</view>
						</view>
						<view class="col-6 align-items-center d-flex col">
							<view class="username ps-2"><label class="w-100">UID::{{userinfo['codes']}}</label><label
									class="username-bold w-100">{{$t('Financial-management-level')}}:
									{{userinfo['member_info']['level_name']}}</label>
								<label class="username-bold w-100"
									v-if="userinfo['service']>0">{{$t('management_level')}}:
									V{{userinfo['service']}}</label><span>{{$t('Date-of-registration')}}:
									{{userinfo['reg_time']}}</span>
							</view>
						</view>
						<view class="col-4 d-flex align-items-center col"><button type="button"
								class="w-100 button-topup  btn-primary"><label
									style="cursor: pointer;">{{$t('userInfo')}}</label></button></view>
						<view class="user-info-panel team">

							<view class="m-0 row">
								<view class="col-6 col"><label class="text-start">{{$t('amount_of_financing')}}</label>
								</view>
								<view class="col-4 col"><label class="text-start">{{userinfo['orderSums']}}</label>
								</view>
							</view>

							<view class="m-0 row">
								<view class="col-6 col"><label class="text-start">{{$t('immediate_income')}}</label>
								</view>
								<view class="col-4 col"><label class="text-start">{{userinfo['refereeBonus']}}</label>
								</view>
							</view>

							<view class="m-0 row">
								<view class="col-6 col"><label class="text-start">{{$t('management_income')}}</label>
								</view>
								<view class="col-4 col"><label class="text-start">{{userinfo['agentBonus']}}</label>
								</view>
							</view>
							<view class="m-0 row">
								<view class="col-6 col"><label class="text-start">{{$t('dividend_income')}}</label>
								</view>
								<view class="col-4 col"><label class="text-start">{{userinfo['fenhong']}}</label></view>
							</view>
							<view class="m-0 row">
								<view class="col-6 col"><label
										class="text-start">{{$t('total_direct_financial')}}</label></view>
								<view class="col-4 col"><label class="text-start">{{userinfo['rmoneys']}}</label></view>
							</view>
							<view class="m-0 row">
								<view class="col-6 col"><label class="text-start">{{$t('direct_number')}}</label></view>
								<view class="col-4 col"><label class="text-start">{{userinfo['rnums']}}</label></view>
							</view>
							<view class="m-0 row">
								<view class="col-6 col"><label class="text-start">{{$t('total_team_financing')}}</label>
								</view>
								<view class="col-4 col"><label class="text-start">{{userinfo['refereemoneys']}}</label>
								</view>
							</view>

							<view class="m-0 row">
								<view class="col-6 col"><label class="text-start">{{$t('team_number')}}</label></view>
								<view class="col-4 col"><label class="text-start">{{userinfo['teamCount']}}</label>
								</view>
							</view>
							<view class="m-0 row">
								<view class="col-6 col"><label class="text-start">{{$t('withdrawal_amount')}}</label>
								</view>
								<view class="col-4 col"><label class="text-start">{{userinfo['tixian']}}</label></view>
							</view>
						</view>
					</view>
				</view>
				<view class="downline-container">
					<view class="downline-card">
						<view class="m-0 row">
							<view class="col-12 col">
								<p class="text-gold bold" style="font-size: 28rpx;">{{$t('My_direct_report')}}</p>
							</view>
						</view>
					</view>

				</view>
				<view class="downline-container">
					<view class="downline-card card" v-for="(item,index) in teamList" :key="index">
						<view class="m-0 row">

							<view class="col-2 col">
								<view class="avatar">
									<u--image :showLoading="false" :src="item.user_headimg" width="40"
										height="40"></u--image>
								</view>
							</view>
							<view class="align-items-start d-flex col">
								<view class="username ps-2">
									<label class="w-100">{{item['codes']}}</label>
									<label class="username-bold w-100">{{$t('Financial-management-level')}}:
										{{item['level_name']}}</label>
									<label class="username-bold w-100"
										v-if="item['service']>0">{{$t('management_level')}}:
										V{{item['service']}}</label><span>{{$t('Date-of-registration')}}:{{item['reg_time']}}</span>
								</view>
							</view>
							<view class="align-items-start d-flex justify-content-end col">
								<view>
									<label class="account-status" :class="item['member_level']>47?'active':''"
										v-if="item['member_level']>47">{{$t('valid_member')}}</label>
									<label class="account-status" :class="item['member_level']>47?'active':''" v-else
										style="color:#c1d1ff">无效会员</label>
									<label for=""></label>
									<view class="account-status" style="color:#f00;display: block;"
										v-if="item.father==userinfo['uid']">
										{{$t('ceo_only')}}
									</view>
								</view>
							</view>
						</view>
						<view class="user-info-panel team">
							<view class="m-0 row">
								<view class="col-6 col"><label>{{$t('amount_of_financing')}}</label></view>
								<view class="col-4 col"><label>{{item['allmoney']}}</label></view>
							</view>

							<view class="m-0 row">
								<view class="col-6 col"><label>{{$t('total_direct_financial')}}</label></view>
								<view class="col-4 col"><label>{{item['rmoneys']}}</label></view>
							</view>
							<view class="m-0 row">
								<view class="col-6 col"><label>{{$t('direct_number')}}</label></view>
								<view class="col-4 col"><label>{{item['rcount']}}</label></view>
							</view>
							<view class="m-0 row">
								<view class="col-6 col"><label>{{$t('total_team_financing')}}</label></view>
								<view class="col-4 col"><label>{{item['refereemoneys']}}</label></view>
							</view>
							<view class="m-0 row">
								<view class="col-6 col"><label>{{$t('team_number')}}</label></view>
								<view class="col-4 col"><label>{{item['teamCount']}}</label></view>
							</view>

						</view>
					</view>



				</view>
			</view>



		</view>
	</view>

	</view>

</template>


<script>
	import topWallet from "@/components/nav/top_wallet.vue"
	export default {
		components: {
			topWallet,
		},
		onLoad: function(options) {

		},
		onShow() {
			this.tui.haslogin();
			if (this.tui.isLogin()) {
				this.init();
				this.setTitle()
			}
		},
		data() {
			return {
				pageIndex: 1,
				loadding: false,
				userinfo: '',
				teamList: []
			}
		},
		methods: {
			recharge() {

			},
			setTitle() {
				uni.setNavigationBarTitle({
					title: this.$t('Team')
				});
			},
			init() {

				let token = this.tui.getToken();
				let datas = {
					token: token,
				};
				let result = this.tui.request('/api/user/userInfos', 'post', datas, 1000, 1, '', 'userInfos');

				Promise.resolve(result).then((value) => {
					if (value.code == 200) {
						this.userinfo = value.data;
					}
				})
				let teamData = {
					token: token,
					page: this.pageIndex
				}
				let results = this.tui.request('/api/user/getMyTeam', 'post', teamData, 1000, 1, '', 'getMyTeam');
				Promise.resolve(results).then((value) => {
					if (value.code == 200) {
						this.teamList = value.data.child;
					}
				})

			},
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onPullDownRefresh() {
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 200)
		},


	}
</script>

<style scoped lang="scss">
	page {
		background-color: #252C46;
		min-height: 100%;
	}

	.recharge_btn {
		background: rgba(193, 209, 255, .2) !important;
		border-right: none;
		border-bottom: none;
		border-radius: 15px;
		box-shadow: 0 4px 4px 0 rgba(0, 0, 0, .25);
		color: var(--Light-Blue-Solid) !important;
		font-size: 12px;
		height: 48px;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.user-info-panels {
		background: #919916;
	}

	.cards {
		background: #f00;
	}
</style>